<script setup>
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';
const { currentRoute } = useRouter();
const router = useRouter();
import { token } from "@/utils/api.js"

// 正式发布
const gettoken = async () => {

    window.sessionStorage.setItem('token', currentRoute.value.query.token);

    let res = await token(currentRoute.value.query.token)
    // if (res.status == 'success') {
    //     window.sessionStorage.setItem('zhName', res.logInfo.zhName);
    //     window.sessionStorage.setItem('mobile', res.logInfo.zhName);
    //     window.sessionStorage.setItem('areaId', res.data);
    //     router.push({ path: '/realTimeMonitoring' });
    if (res.code == '200') {
        let data = res.data;
        // let msg = {
        //     username: data.username,
        //     zhName: data.zhName,
        //     manageList: data.manageList,
        //     areaId: data.areaId
        // }
        window.sessionStorage.setItem('zhName', data.zhName);
        window.sessionStorage.setItem('mobile', data.mobile);
        window.sessionStorage.setItem('areaId', data.areaId);
        router.push({ path: '/realTimeMonitoring' });
    } else {
        alert('服务器异常，请稍后再试')
    }
}

// 测试
const login = () => {
    window.sessionStorage.setItem('zhName', '石门台');
    window.sessionStorage.setItem('mobile', '18201550364');
    window.sessionStorage.setItem('areaId', '0000078');
    router.push({ path: '/realTimeMonitoring' });
}

onMounted(() => {
    // 正式发布
    if (currentRoute.value.query.token == undefined) {
        alert('您暂无权限查看，请登录后再查看')
    } else {
        gettoken();
    }

    // 测试
    // login();
})

</script>
<template>
    <div>

    </div>
</template>
<style scoped></style>